/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package proyectotsm;

/**
 * Clase Controles.java
 *
 * @author srgank
 * @author juancarlos
 * @author gabriel
 */
public class Controles extends javax.swing.JFrame {

    /** Creates new form Controles */
    public Controles() {
        initComponents();
        inv = false;
        ther = false;
        valor = 0;
    }

    /**
     * Comparamos si las opciones estan activadas
     */
    public boolean isTher() {
        return ther;
    }

    public boolean istinv() {
        return inv;
    }

    public boolean issepia() {
        return sepia;
    }

    /**
     * El valor del slider
     * @return the valor
     */
    public double getValor() {
        return valor;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        invertir = new javax.swing.JRadioButton();
        Nada = new javax.swing.JRadioButton();
        Thereshold = new javax.swing.JRadioButton();
        SliderTher = new javax.swing.JSlider();
        valorSlider = new javax.swing.JTextField();
        Sepia = new javax.swing.JRadioButton();

        buttonGroup1.add(invertir);
        invertir.setText("Invertir");
        invertir.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                invertirStateChanged(evt);
            }
        });
        invertir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                invertirActionPerformed(evt);
            }
        });

        buttonGroup1.add(Nada);
        Nada.setText("Nada");
        Nada.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                NadaStateChanged(evt);
            }
        });
        Nada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NadaActionPerformed(evt);
            }
        });

        buttonGroup1.add(Thereshold);
        Thereshold.setText("Thereshold");
        Thereshold.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                TheresholdStateChanged(evt);
            }
        });

        SliderTher.setMaximum(255);
        SliderTher.setValue(127);
        SliderTher.setEnabled(false);
        SliderTher.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SliderTherStateChanged(evt);
            }
        });

        valorSlider.setText("127");
        valorSlider.setEnabled(false);

        buttonGroup1.add(Sepia);
        Sepia.setText("Sepia");
        Sepia.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SepiaStateChanged(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(108, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(SliderTher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(92, 92, 92))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(valorSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(179, 179, 179))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Thereshold)
                            .addComponent(invertir)
                            .addComponent(Nada)
                            .addComponent(Sepia))
                        .addGap(128, 128, 128))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(98, 98, 98)
                .addComponent(Nada)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Sepia)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(invertir)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Thereshold)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SliderTher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(valorSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(59, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void invertirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_invertirActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_invertirActionPerformed

    private void invertirStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_invertirStateChanged
        if (invertir.isSelected()) {
            inv = true;
        } else {
            inv = false;
        }
    }//GEN-LAST:event_invertirStateChanged

    private void NadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NadaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_NadaActionPerformed

    private void NadaStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_NadaStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_NadaStateChanged

    private void TheresholdStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_TheresholdStateChanged
        if (Thereshold.isSelected()) {
            ther = true;
            SliderTher.setEnabled(true);

        } else {
            ther = false;
            SliderTher.setEnabled(false);
        }
    }//GEN-LAST:event_TheresholdStateChanged

    private void SliderTherStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SliderTherStateChanged
        valorSlider.setText(String.valueOf(SliderTher.getValue()));
        valor = SliderTher.getValue();
    }//GEN-LAST:event_SliderTherStateChanged

    private void SepiaStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SepiaStateChanged
        if (Sepia.isSelected()) {
            sepia = true;
        } else {
            sepia = false;
        }
    }//GEN-LAST:event_SepiaStateChanged

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Controles().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton Nada;
    private javax.swing.JRadioButton Sepia;
    private javax.swing.JSlider SliderTher;
    private javax.swing.JRadioButton Thereshold;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton invertir;
    private javax.swing.JTextField valorSlider;
    // End of variables declaration//GEN-END:variables
    private boolean inv;
    private boolean ther;
    private double valor;
    private boolean sepia;
}
